<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4]
    let obj = {}
    let result = []

    arr.forEach((item, index) => {
        obj[arr[index]] = obj[arr[index]] ? obj[arr[index]] + 1 : 1
    })

    console.log(obj)  // {1: 3, 2: 3, 3: 4, 4: 2}

    Object.keys(obj).forEach(item => {  // 这儿的 item 是下标
        if (obj[item] > 2) {
            result.push(+item)  // 将字符串改为整型
        }
    })
    console.log(result) // [1,2,3]
</script>
</body>
</html>